#include "src/json/json_parser.h"

using aquawius::json::logger::Logger;
using aquawius::json::logger::LOG_LEVELS;
using aquawius::json::JsonParser;

int main()
{
    // Logger::log(LOG_LEVELS::INFO, "Starting main()");

    // C++11 Raw string;
    // char str[] = R"JSON()JSON";
    // char str[] = R"JSON(42)JSON";
    // char str[] = R"JSON('s\65x5klkasd')JSON";

    // char str[] = R"JSON([])JSON";
    // char str[] = R"JSON([1])JSON";
    // char str[] = R"JSON([1,[1,"st\]ring\\]"],"string",2,3])JSON";
    // char str[] = R"JSON([1,[1,"st\]ring\\]"],"string",2,3])JSON";

    // char str[] = R"JSON({})JSON";
    // char str[] = R"JSON({"aquawius":"NB"})JSON";
    // char str[] = R"JSON({"aquawius":"NB","age":12})JSON";
    // char str[] = R"JSON({"a":{"aquawius":"NB"},"a":[3,4]})JSON";

    // char str[] = R"JSON(
    // {
    //     "b" : [   3 , { "666" :  666  } ] ,
    // }
    // )JSON";

    // char str[] = R"JSON(
    // {
    //           "isRegex" : ttrue   ,
    // }
    //       )JSON";

    // char str[] = R"JSON({ "people": [
    //   { "firstName" : "Brett", "lastName":"McLaughlin", "email": "brett@newInstance.com" },
    //   { "firstName": "Jason", "lastName":"Hunter", "email": "jason@servlets.com" },
    //   { "firstName": "Elliotte", "lastName":"Harold", "email": "elharo@macfaq.com" }
    // ]}
    // )JSON";

    // char str[] = R"JSON({"aquawius":"NB","array":[12,"string"]})JSON";

    // middle test.
      char str[] = R"JSON(
      {
          "a" : {  "aquawius" :"NB", "name": "Jack" }       ,
          "b" : [   3 , { "666" :  666  } , [ true, "hahah",  false, true ] ] ,

          "aquawius" : "hahahahah"  ,
          "shop" : 1000.10    ,
          "isRegex" : true   ,
          "isLiteral" : false   ,
          "NULL" : null    ,
          "16hex" : "\x10\x23\x65\x78\x69\x65"

      }
      )JSON";

    // final test

    /*
    char str[] = R"JSON(
{
  "userProfile": {
    "16hex" : "\x10\x23\x65\x78\x69\x65",
    "userId": "12345",
    "username": "test_user",
    "email": "test_user@example.com",
    "personalInfo": {
      "firstName": "Test",
      "lastName": "User",
      "age": 30,
      "gender": "non-binary",
      "address": {
        "street": "456 Test St",
        "city": "Testville",
        "state": "TX",
        "zipCode": "78910",
        "country": "USA"
      }
    },
    "preferences": {
      "languages": ["English", "Spanish", "French", "German", "Chinese"],
      "theme": "dark",
      "notifications": {
        "email": true,
        "sms": false,
        "push": true
      },
      "privacySettings": {
        "showProfilePicture": true,
        "shareActivityStatus": false,
        "adPersonalization": true
      }
    },
    "activityLog": [
      {
        "date": "2024-06-30T12:00:00Z",
        "action": "login",
        "ip": "192.168.1.1"
      },
      {
        "date": "2024-06-29T14:22:33Z",
        "action": "update_profile",
        "changes": {
          "email": "new_email@example.com",
          "address": {
            "city": "New Testville",
            "zipCode": "89123"
          }
        }
      },
      {
        "date": "2024-06-28T10:15:45Z",
        "action": "logout"
      }
    ]
  },
  "projects": [
    {
      "projectId": "A1",
      "title": "Project Alpha",
      "description": "A project about Alpha.",
      "teamMembers": ["Alice", "Bob", "Charlie"],
      "milestones": [
        {
          "milestoneId": "M1",
          "title": "Design Phase",
          "deadline": "2024-07-15",
          "completed": false,
          "tasks": [
            {
              "taskId": "T1",
              "title": "Create wireframes",
              "status": "in progress"
            },
            {
              "taskId": "T2",
              "title": "Review wireframes",
              "status": "not started"
            }
          ]
        },
        {
          "milestoneId": "M2",
          "title": "Development Phase",
          "deadline": "2024-08-30",
          "completed": false,
          "tasks": [
            {
              "taskId": "T3",
              "title": "Develop backend",
              "status": "not started"
            },
            {
              "taskId": "T4",
              "title": "Develop frontend",
              "status": "not started"
            }
          ]
        }
      ]
    },
    {
      "projectId": "B1",
      "title": "Project Beta",
      "description": "A project about Beta.",
      "teamMembers": ["Dave", "Eve", "Frank"],
      "milestones": [
        {
          "milestoneId": "M3",
          "title": "Research Phase",
          "deadline": "2024-06-30",
          "completed": true,
          "tasks": [
            {
              "taskId": "T5",
              "title": "Conduct literature review",
              "status": "completed"
            },
            {
              "taskId": "T6",
              "title": "Compile findings",
              "status": "completed"
            }
          ]
        },
        {
          "milestoneId": "M4",
          "title": "Implementation Phase",
          "deadline": "2024-09-01",
          "completed": false,
          "tasks": [
            {
              "taskId": "T7",
              "title": "Set up infrastructure",
              "status": "not started"
            },
            {
              "taskId": "T8",
              "title": "Develop features",
              "status": "not started"
            }
          ]
        }
      ]
    }
  ],
  "productCatalog": {
    "categories": [
      {
        "categoryId": "C1",
        "name": "Electronics",
        "products": [
          {
            "productId": "P1",
            "name": "Smartphone",
            "price": 699.99,
            "specifications": {
              "brand": "BrandX",
              "model": "X100",
              "features": [
                "5G",
                "128GB Storage",
                "6GB RAM"
              ]
            }
          },
          {
            "productId": "P2",
            "name": "Laptop",
            "price": 1299.99,
            "specifications": {
              "brand": "BrandY",
              "model": "Y200",
              "features": [
                "16GB RAM",
                "512GB SSD",
                "Intel i7"
              ]
            }
          }
        ]
      },
      {
        "categoryId": "C2",
        "name": "Home Appliances",
        "products": [
          {
            "productId": "P3",
            "name": "Vacuum Cleaner",
            "price": 299.99,
            "specifications": {
              "brand": "BrandZ",
              "model": "Z300",
              "features": [
                "Bagless",
                "HEPA Filter",
                "Cordless"
              ]
            }
          },
          {
            "productId": "P4",
            "name": "Microwave Oven",
            "price": 199.99,
            "specifications": {
              "brand": "BrandA",
              "model": "A400",
              "features": [
                "1000W",
                "Convection",
                "Digital Display"
              ]
            }
          }
        ]
      }
    ]
  }
}

)JSON";
*/


    std::cout << "origin string:" << std::endl;
    std::cout << str << std::endl;

    JsonParser parser;
    auto result = JsonParser::parseJson(str);

    std::cout << "///////////////////////////////////////////" << std::endl;
    const auto& json_object = result;
    // auto visitor = [&](auto const& subInner)
    // {
    //     std::cout << typeid(subInner).name() << std::endl;
    // };
    // std::visit(visitor, json_object.inner);

    JsonParser::printJsonObject(json_object, std::cout);
    std::cout << std::endl;
    // Logger::log(LOG_LEVELS::INFO, "Ending main()");

    std::cout << "///////////////////////////////////////////" << std::endl;
    // auto val = json_object.getValue("aquawius");
    // auto val = json_object.getValue("shop");
    auto val = json_object.getValue("b");
    auto valint = val.getValue("3");

    JsonParser::printJsonObject(val, std::cout );
    JsonParser::printJsonObject(valint, std::cout );

    return 0;
}
